package uform.model.cell;

import uform.model.cell.ArrayCell;
import uform.model.cell.ValueCell;
import uform.model.value.StringType;
import utest.Assert;

class TestCell extends Test
{
	public function testValidation()
	{
		var field = new ValueCell(new StringType(), true);
		assertValidation(field.validate(null), true);
		assertValidation(field.validate("a"), true);
		assertValidation(field.validate([]), false);
		assertValidation(field.validate([null]), false);
		
		var field = new ValueCell(new StringType());
		assertValidation(field.validate(null), false);
		assertValidation(field.validate("a"), true);
		
		var field = new ArrayCell(new StringType());
		assertValidation(field.validate(null), true);
		assertValidation(field.validate([]), true);
		assertValidation(field.validate([null]), false);
		assertValidation(field.validate(["a"]), true);
		
		var field = new ArrayCell(new StringType());
		assertValidation(field.validate(null), true);
		assertValidation(field.validate([]), true);
		assertValidation(field.validate([null]), false);
		assertValidation(field.validate(["a"]), true);
		
		var field = new ArrayCell(new StringType(), 1, 2);
		assertValidation(field.validate(["a"]), true);
		assertValidation(field.validate(["a","b"]), true);
		assertValidation(field.validate(["a", "b", "c"]), false);
		assertValidation(field.validate(["a",null]), false);
	}
	
	public function new();
}